package com.nan.gbd.library.codec;

public class MediaCodecConfig {
    private int frameRate;
    private int iframeInterval;
    private int mThreadNum;//设置编码线程数
    private int mAvQueueSize;//设置编码最大缓存队列大小
    private double mVideoBitrateFactor;//设置视频比特率上下浮动因子
    private int mVideoBitrateAdjustPeriod;//设置视频比特率动态调整周期
    private int mStreamStatPeriod;//设置流状态统计周期
    private int videoBitRate;//设置流状态统计周期
    private String profile;
    private String bitrateMode;
    private String vencodec;//视频编码类型
    private String videoType;

    private String audioType;
    private int sampleRate;
    private int channelCount;
    private int audioFormat;
    private int bitRate;
    private int maxInputSize;

    public MediaCodecConfig(int frameRate, int iframeInterval, int mThreadNum, int mAvQueueSize, double mVideoBitrateFactor, int mVideoBitrateAdjustPeriod, int mStreamStatPeriod, String profile, String bitrateMode, String vencodec, String videoType, String audioType, int sampleRate, int channelCount, int audioFormat, int bitRate, int maxInputSize) {
        this.frameRate = frameRate;
        this.iframeInterval = iframeInterval;
        this.mThreadNum = mThreadNum;
        this.mAvQueueSize = mAvQueueSize;
        this.mVideoBitrateFactor = mVideoBitrateFactor;
        this.mVideoBitrateAdjustPeriod = mVideoBitrateAdjustPeriod;
        this.mStreamStatPeriod = mStreamStatPeriod;
        this.profile = profile;
        this.bitrateMode = bitrateMode;
        this.vencodec = vencodec;
        this.videoType = videoType;
        this.audioType = audioType;
        this.sampleRate = sampleRate;
        this.channelCount = channelCount;
        this.audioFormat = audioFormat;
        this.bitRate = bitRate;
        this.maxInputSize = maxInputSize;
    }



    public int getFrameRate() {
        return frameRate;
    }

    public int getVideoBitRate() {
        return videoBitRate;
    }

    public int getIframeInterval() {
        return iframeInterval;
    }

    public int getmThreadNum() {
        return mThreadNum;
    }

    public int getmAvQueueSize() {
        return mAvQueueSize;
    }

    public double getmVideoBitrateFactor() {
        return mVideoBitrateFactor;
    }

    public int getmVideoBitrateAdjustPeriod() {
        return mVideoBitrateAdjustPeriod;
    }

    public int getmStreamStatPeriod() {
        return mStreamStatPeriod;
    }

    public String getProfile() {
        return profile;
    }

    public String getBitrateMode() {
        return bitrateMode;
    }

    public String getVencodec() {
        return vencodec;
    }

    public String getVideoType() {
        return videoType;
    }



    public String getAudioType() {
        return audioType;
    }

    public int getSampleRate() {
        return sampleRate;
    }

    public int getChannelCount() {
        return channelCount;
    }

    public int getAudioFormat() {
        return audioFormat;
    }

    public int getBitRate() {
        return bitRate;
    }

    public int getMaxInputSize() {
        return maxInputSize;
    }


    public String toVideoString() {
        return "MediaCodecConfig{" +
                ", frameRate=" + frameRate +
                ", iframeInterval=" + iframeInterval +
                ", mThreadNum=" + mThreadNum +
                ", mAvQueueSize=" + mAvQueueSize +
                ", mVideoBitrateFactor=" + mVideoBitrateFactor +
                ", mVideoBitrateAdjustPeriod=" + mVideoBitrateAdjustPeriod +
                ", mStreamStatPeriod=" + mStreamStatPeriod +
                ", videoBitRate=" + videoBitRate +
                ", profile='" + profile + '\'' +
                ", bitrateMode='" + bitrateMode + '\'' +
                ", vencodec='" + vencodec + '\'' +
                ", videoType='" + videoType + '\'' +
                '}';
    }

    public String toAudioString() {
        return "MediaCodecConfig{" +
                "audioType='" + audioType + '\'' +
                ", sampleRate=" + sampleRate +
                ", channelCount=" + channelCount +
                ", audioFormat=" + audioFormat +
                ", bitRate=" + bitRate +
                ", maxInputSize=" + maxInputSize +
                '}';
    }

    public static class Builder {
        private int frameRate;
        private int iframeInterval;
        private int mThreadNum;//设置编码线程数
        private int mAvQueueSize;//设置编码最大缓存队列大小
        private double mVideoBitrateFactor;//设置视频比特率上下浮动因子
        private int mVideoBitrateAdjustPeriod;//设置视频比特率动态调整周期
        private int mStreamStatPeriod;//设置流状态统计周期
        private String profile;
        private String bitrateMode;
        private String vencodec;//视频编码类型
        private String videoType;


        private String audioType;
        private int sampleRate;
        private int channelCount;
        private int audioFormat;
        private int bitRate;
        private int maxInputSize;




        public Builder setFrameRate(int frameRate) {
            this.frameRate = frameRate;
            return this;
        }

        public Builder setIframeInterval(int iframeInterval) {
            this.iframeInterval = iframeInterval;
            return this;
        }

        public Builder setmThreadNum(int mThreadNum) {
            this.mThreadNum = mThreadNum;
            return this;
        }

        public Builder setmAvQueueSize(int mAvQueueSize) {
            this.mAvQueueSize = mAvQueueSize;
            return this;
        }

        public Builder setmVideoBitrateFactor(double mVideoBitrateFactor) {
            this.mVideoBitrateFactor = mVideoBitrateFactor;
            return this;
        }

        public Builder setmVideoBitrateAdjustPeriod(int mVideoBitrateAdjustPeriod) {
            this.mVideoBitrateAdjustPeriod = mVideoBitrateAdjustPeriod;
            return this;
        }

        public Builder setmStreamStatPeriod(int mStreamStatPeriod) {
            this.mStreamStatPeriod = mStreamStatPeriod;
            return this;
        }

        public Builder setProfile(String profile) {
            this.profile = profile;
            return this;
        }

        public Builder setBitrateMode(String bitrateMode) {
            this.bitrateMode = bitrateMode;
            return this;
        }

        public Builder setVencodec(String vencodec) {
            this.vencodec = vencodec;
            return this;
        }

        public Builder setVideoType(String videoType) {
            this.videoType = videoType;
            return this;
        }

        public Builder setAudioType(String audioType) {
            this.audioType = audioType;
            return this;
        }

        public Builder setSampleRate(int sampleRate) {
            this.sampleRate = sampleRate;
            return this;
        }

        public Builder setChannelCount(int channelCount) {
            this.channelCount = channelCount;
            return this;
        }

        public Builder setAudioFormat(int audioFormat) {
            this.audioFormat = audioFormat;
            return this;
        }

        public Builder setBitRate(int bitRate) {
            this.bitRate = bitRate;
            return this;
        }

        public Builder setMaxInputSize(int maxInputSize) {
            this.maxInputSize = maxInputSize;
            return this;
        }

        public MediaCodecConfig builder() {
            return new MediaCodecConfig(frameRate, iframeInterval, mThreadNum, mAvQueueSize, mVideoBitrateFactor, mVideoBitrateAdjustPeriod, mStreamStatPeriod, profile, bitrateMode, vencodec, videoType, audioType, sampleRate, channelCount, audioFormat, bitRate, maxInputSize);
        }

        @Override
        public String toString() {
            return "Builder{" +
                    ", frameRate=" + frameRate +
                    ", iframeInterval=" + iframeInterval +
                    ", mThreadNum=" + mThreadNum +
                    ", mAvQueueSize=" + mAvQueueSize +
                    ", mVideoBitrateFactor=" + mVideoBitrateFactor +
                    ", mVideoBitrateAdjustPeriod=" + mVideoBitrateAdjustPeriod +
                    ", mStreamStatPeriod=" + mStreamStatPeriod +
                    ", profile='" + profile + '\'' +
                    ", bitrateMode='" + bitrateMode + '\'' +
                    ", vencodec='" + vencodec + '\'' +
                    ", videoType='" + videoType + '\'' +
                    ", audioType='" + audioType + '\'' +
                    ", sampleRate=" + sampleRate +
                    ", channelCount=" + channelCount +
                    ", audioFormat=" + audioFormat +
                    ", bitRate=" + bitRate +
                    ", maxInputSize=" + maxInputSize +
                    '}';
        }
    }
}
